const express = require('express');

const app = express();

const config = require('./config/config.js')

app.use('/uploads', express.static('./uploads')) // 静态地址

const bodyParser = require('body-parser');

app.set('secret', 'ahsg#sj$sasd%') // jwt 密钥

app.use(require('cors')()) // 解决跨越问题

app.get('/', async(req, res) => {
    res.send('Hello');
})

app.use(bodyParser.json());

app.use(bodyParser.urlencoded({
    extended: true
}));

require("./plugins/db")(app) // 数据库
require("./router/admin/index")(app) // 服务端 api
require("./router/admin/user")(app) // 服务端 用户 api
require("./router/web/index")(app) // 用户端 api

app.listen(config.HOST,  async () => {
    console.log(`http://localhost:${config.HOST}`)
})